home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-01-15 | 46.8 KB | 1,761 lines |
- *** 1.61 1991/09/24 16:44:02
- --- Changelo 1992/01/14 18:50:57
- ***************
- *** 2396,2398 ****
- --- 2396,2622 ----
-
-
- ---------------------------- Patchlevel 73 ---------------------------
- +
- + popen.c:: ++jrb
- + use tmpnam() to get temp filename. That way $TEMP || $TMPDIR
- + get looked up.
- +
- + main.c:: ++jrb
- + moved clearing of errno to just before calling main(). otherwise
- + somehow is was !=0 at the start of main() in some cases.
- +
- + unlink.c:: scott
- + i cant believe this was still lurking in there. Thanks scott!!
- + if the file to be unlinked was open, and we put it in the
- + atexit chain, we were'nt strduping the filename, as a result
- + all filenames in the chain were pointing to the same loc.
- + arrgggh! now strdup() the name, and free it in do_deletes. if
- + the strdup() fails, link it in the chain with a null filename,
- + and in do_deletes() just skip over entries with null
- + filenames. we need to do this as we cannot un-atext the entry,
- + nor do we want to as they may be others in the chain before
- + this one, or successive attempts may succeed.
- +
- + main.c:: ++jrb
- + call the atexit functions after closing all the open files.
- + this is essential if the deferred unlinks() etc are going to
- + work.
- +
- + binmode.c:: ers
- + new file. as per mntlib pl 13, __default_mode__ is now a
- + global that the user may define. if not defined by the user
- + it gets picked up from here, with a default value of 0 (text mode)
- + the user may now define __default_mode__ = IOBIN; and that
- + way stdin etc get opened in binary mode. thanks eric.
- +
- + fdopen.c fopen.c main.c:: ers
- + adjustments for __default_mode__.
- +
- + mincl:: ++jrb
- + add target for binmode.o
- +
- + localtim.c:: ers
- + sync with mintlib, use symbolic constants
- +
- + main.c,spawnve.c,findfile.c: ers
- + when starting up, convert the environment variable PATH to
- + POSIX form (i.e. using ':' as a separator); when execing a
- + new program, convert back to old form so old programs will
- + work correctly. thanks eric.
- +
- + fread.c:: jeffrey jackson (jgj@ssd.csd.harris.com)
- + fread was'nt returning EOF on large reads. thanks jeffrey.
- +
- + mktemp.c rename.c symlink.c:: ++jrb
- + save errno around calls to access()
- +
- + symlink.c:: jeffrey
- + the length returned was wrong because we were doing a strncpy
- + before strlen.
- +
- + main.c:: ++jrb
- + for stdin/out/err set open_stat[].filename to the unix device
- + so that fstat() works. thanks to jeffrey for discovering this.
- +
- + pipe.c, close.c:: scott
- + minor fixes for pipes. bash-1.10 works real well now.
- +
- + stat.c: jeff
- + handle the case for fstat() when stdin/out etc are re-directed.
- + (ie: open_stat[].filename == NULL).
- +
- + unx2dos.c:: jeff
- + overwrite __link_to only once when following links, so that
- + lstat() works correctly.
- +
- + symlink.c:: jeff
- + readlink didn't work for symbolic links in root file system if
- + the passed name had the slash. This was because the slashed
- + was nulled to create the directory name of the file (boundry
- + condition type bug).
- +
- + scanf.c:: ++jrb
- + %n was'nt storing the # of chars read in so far, but was storing
- + number of conversions done. thnaks for allan pratt for reporting
- + this.
- +
- + scanf.c:: ++jrb
- + old one had too many subtle problems. replaced with one from
- + gnu libc with a few subtle corrections, and also a bug fix.
- + NOTES:
- + - interface is different from equivalent gnuC lib function
- + it was munged to match our old _scanf().
- + - if __NO_FLOAT__ is defined then the floating point stuff
- + gets nuked (for iio*.olb) as per our old scanf.c.
- +
- + It is very important to read and understand the GNU Library General
- + Public License. It specifies rights and conditions that are different
- + from the GNU copyleft.
- +
- + atof.c:: ++jrb
- + strtod() was leaving the pointer one char too far when input
- + had a tailing 'e' (for example after 100ergs, the endptr would
- + be pointing to 'r' rather than 'e').
- +
- + scanf.c:: ++jrb
- + had to hack it quite a bit to get out bugs. the regression test
- + is great now!
- +
- + crt0.c:: ++jrb
- + More meanings for _stksize (thanks to eric and allan for the feedback)
- +
- + _stksize meaning
- + -4L keep 3/4, free 1/4, malloc from own heap
- + -3L keep 2/4 (1/2), free 1/2 malloc from own heap
- + -2L keep 1/4 of memory, free 3/4, malloc from own heap
- +
- + NOTE: all of the following will do malloc from Malloc() first,
- + when that fails, malloc() will do further mallocs from
- + our own heap. This lets us use the maximum amount of
- + memory in traditional ST's as well as newer split address
- + STs.
- +
- + -1L keep all of memory (except MINFREE at top) and do
- + mallocs from own heap, with heap grown upwards towards
- + stack, and the stack growing down towards heap,
- + with a minimum slush between them so that they
- + dont meet (only checked while malloc'ing). With
- + this model, further spawning is not possible, but it is
- + well suited for programs such as gcc-cc1 etc.
- + Thanks to Piet van Oostrum & Atze Dijkstra for this idea
- +
- + 0L keep minimum amount of memory. this is also the
- + case when _stksize is undefined by the user.
- + 1L keep 1/4 of memory, free 3/4 ( as in Alcyon GEMSTART)
- + 2L keep 2/4 (1/2), free rest
- + 3L keep 3/4, free 1/4
- + other keep that many bytes
- + -other keep |other| bytes and malloc from own heap
- +
- +
- + Also note that when _initial_size is specified, malloc happens from own
- + heap only.
- +
- + crt0.c:: ++jrb
- + New convention for ACCs: (the old convention is still supported):
- +
- + If _heapbase is not specified by the user, _stksize bytes will
- + be Malloc()'ed from the system, and _heapbase will be set to
- + this area, and sp will be set to the top of the allocated
- + area. All malloc()'s of course will happen from this local heap.
- +
- + The old convention for ACCs where the _heapbase and _stksize
- + were specified, and sp was set to _heapbase+_stksize will
- + continue to work.
- +
- + malloc.c, sbrk.c:: ++jrb
- + implement _split_mem for _stksize >= -1L. get mem from
- + Malloc first, after that is exhausted, start carving out of
- + own heap (the heap will be in the other address space of the
- + split address space). (ie: other to the one the program is
- + launched in). The way this is done is that when _stksize >= -1L
- + in crt0.c the vars _split_mem and _heapbase are set in crt0.c.
- + then whenever we sbrk, we first check _split_mem, which if true
- + causes us to Malloc(). Then when Malloc() fails, and if _split_mem
- + was on, we turn it off and that causes sbrk() to start allocing from
- + heap.
- +
- + crt0.c:: ++jrb
- + in _start1() the local vars and args MUST be in registers because
- + we are playing games with SP and the FP. to ensure this use
- + __asm("REG") facility of gcc. thanks allan.
- +
- + isatty.c:: ++jrb
- + put in a check so that PRN: always returns false. i believe
- + that this will fix the problem of GS and gnuplot,
- + where fwrite() to a file opened in binary mode to PRN: was munging
- + the bytes on the way to the printer. Unfortunately, i dont
- + have a printer attached to my ST to check.
- + Tim says its ok now. GS works!
- +
- + unistd.h, mkdir.c:: andreas schwab
- + mkdir takes a second mode argument (currently ignored).
- + thanks andreas.
- +
- + basepage.h:: ers
- + make undocumented parts of the BP hard to get at.
- +
- + compiler.h:: ers
- + as per mntlib PL16. note that wchar_t is now an int.
- +
- + time.h:: ers
- + per mntlib pl 16
- +
- + sys/timeb.h:: ers
- + new file
- +
- + timeoday.c:: ers
- + New file.
- + New BSD-ish ftime(), gettimeofday() and settimeofday() system calls.
- +
- + mincl:: ers
- + add target for timeoday.
- +
- + spawnve.c:: ers
- + use TOS_ARGS instead of NCARGS
- +
- + pipe.c:: ers/scott
- + Eric beet down the MiNT/PIPE bug, and I must say with two trivial
- + changes the dup2/pipe interface works quite well. Under MiNT
- + file handles are not automatically shared with children. So
- + the dup2 in bash/emacs was failing.
- +
- + getpass.c, mincl, unistd.h :: ers
- + new file from mintlib for getpass(). Add target to mincl. Add
- + proto to unistd.h. Note: you need to put the final '\n' yourself,
- + after the call to getpass().
- +
- + getpass.c:: ++jrb
- + Null terminate return string (was being passed back with \n)
- + If fget retuns a Null pass back Null (per man on the sun).
- +
- + gmon.c:: ++jrb
- + we collectively decided that all xbra's should be chained via
- + the next's. make adjustments to unlink_handler.
- +
- + ---------------------------- Patchlevel 74 ---------------------------
- *** 1.49 1991/09/24 16:44:02
- --- PatchLev.h 1992/01/14 18:50:58
- ***************
- *** 1,5 ****
-
- ! #define PatchLevel "73"
-
- /*
- *
- --- 1,5 ----
-
- ! #define PatchLevel "74"
-
- /*
- *
- *** 1.18 1991/05/30 04:10:51
- --- atof.c 1992/01/14 18:51:05
- ***************
- *** 239,244 ****
- --- 239,245 ----
- register short texp = 0;
- register short e = 0;
- double zero = 0.0;
- + const char *tmp;
-
- assert ((s != NULL));
-
- ***************
- *** 280,286 ****
- {
- if(*++s != '\0') /* skip e|E|d|D */
- { /* ! ([s]xxx[.[yyy]]e) */
- !
- while(Isspace(*s)) s++; /* Ansi allows spaces after e */
- if(*s != '\0')
- { /* ! ([s]xxx[.[yyy]]e[space]) */
- --- 281,287 ----
- {
- if(*++s != '\0') /* skip e|E|d|D */
- { /* ! ([s]xxx[.[yyy]]e) */
- ! tmp = s;
- while(Isspace(*s)) s++; /* Ansi allows spaces after e */
- if(*s != '\0')
- { /* ! ([s]xxx[.[yyy]]e[space]) */
- ***************
- *** 303,308 ****
- --- 304,310 ----
- texp += e;
- }
- }
- + if(s == tmp) s++; /* back up pointer for a trailing e|E|d|D */
- }
- }
-
- *** 1.12 1991/09/24 16:44:02
- --- close.c 1992/01/14 18:51:08
- ***************
- *** 3,59 ****
- * Copyright (c) 1988, Memorial University of Newfoundland
- *
- */
- #include <osbind.h>
- #include <fcntl.h>
- #include <device.h>
- #include <stdlib.h>
-
- #ifdef DEBUG
- #include <stdio.h>
- #endif
-
- int close(fd)
- ! int fd;
- {
- ! int oldfd;
- ! extern int errno;
- ! int rval;
- ! struct _device *dev;
- !
- ! if ((dev = _dev_fd(fd)) && dev->close)
- ! return (*dev->close)(fd);
- !
- ! oldfd = fd;
- ! fd = __OPEN_INDEX(fd);
- ! if ((fd >= 0) && (fd < __NHANDLES))
- {
- ! if (__open_stat[fd].pipe)
- ! {
- rval = pipeclose(oldfd);
- ! return(rval);
- ! }
- ! else
- if((__open_stat[fd].status == FH_ISAFILE) &&
- (__open_stat[fd].filename))
- free(__open_stat[fd].filename);
- ! __open_stat[fd].status = FH_UNKNOWN;
- ! __open_stat[fd].append = 0;
- ! __open_stat[fd].nodelay = 0;
- ! __open_stat[fd].pipe = 0;
- ! __open_stat[fd].eclose = 0;
- ! __open_stat[fd].filename = (char *) 0;
- ! }
- !
- ! if ((rval = Fclose(oldfd)) < 0) {
- ! errno = -rval;
- ! rval = -1;
- ! }
- !
- !
- #ifdef DEBUG
- ! fprintf(stderr, "close(%d)->%d\n", (fd + __SMALLEST_VALID_HANDLE),
- ! rval);
- #endif
- ! return rval;
- }
-
- --- 3,67 ----
- * Copyright (c) 1988, Memorial University of Newfoundland
- *
- */
- + #include <compiler.h>
- #include <osbind.h>
- #include <fcntl.h>
- #include <device.h>
- #include <stdlib.h>
-
- + __EXTERN int pipeclose __PROTO((int fd));
- +
- #ifdef DEBUG
- #include <stdio.h>
- #endif
-
- int close(fd)
- ! int fd;
- {
- ! int oldfd;
- ! extern int errno;
- ! int rval;
- ! struct _device *dev;
- !
- ! if ((dev = _dev_fd(fd)) && dev->close)
- ! return (*dev->close)(fd);
- ! oldfd=fd;
- ! fd = __OPEN_INDEX(fd);
- !
- ! if ((fd >= 0) && (fd < __NHANDLES))
- ! {
- ! if (__open_stat[fd].pipe)
- {
- ! if (oldfd < 3)
- ! {
- ! __open_stat[fd].pipe = 0;
- ! rval = close(oldfd);
- ! }
- ! else
- rval = pipeclose(oldfd);
- ! return(rval);
- ! }
- ! else
- if((__open_stat[fd].status == FH_ISAFILE) &&
- (__open_stat[fd].filename))
- free(__open_stat[fd].filename);
- ! __open_stat[fd].status = FH_UNKNOWN;
- ! __open_stat[fd].append = 0;
- ! __open_stat[fd].nodelay = 0;
- ! __open_stat[fd].pipe = 0;
- ! __open_stat[fd].eclose = 0;
- ! __open_stat[fd].filename = (char *) 0;
- ! }
- !
- ! if ((rval = Fclose(oldfd)) < 0) {
- ! errno = -rval;
- ! rval = -1;
- ! }
- !
- #ifdef DEBUG
- ! fprintf(stderr, "close(%d)->%d\n", (fd + __SMALLEST_VALID_HANDLE),
- ! rval);
- #endif
- ! return rval;
- }
-
- *** 1.17 1991/09/24 16:44:02
- --- crt0.c 1992/01/14 18:51:08
- ***************
- *** 15,21 ****
- --- 15,34 ----
- * 01/03/89 ++jrb
- * The (new) meaning of _stksize: (thanks to allan pratt for the feedback)
- *
- + * 11/27/91 ++jrb
- + * More meanings for _stksize (thanks to eric and allan for the feedback)
- + *
- * _stksize meaning
- + * -4L keep 3/4, free 1/4, malloc from own heap
- + * -3L keep 2/4 (1/2), free 1/2 malloc from own heap
- + * -2L keep 1/4 of memory, free 3/4, malloc from own heap
- + *
- + * NOTE: all of the following will do malloc from Malloc() first,
- + * when that fails, malloc() will do further mallocs from
- + * our own heap. This lets us use the maximum amount of
- + * memory in traditional ST's as well as newer split address
- + * STs.
- + *
- * -1L keep all of memory (except MINFREE at top) and do
- * mallocs from own heap, with heap grown upwards towards
- * stack, and the stack growing down towards heap,
- ***************
- *** 31,37 ****
- * 2L keep 2/4 (1/2), free rest
- * 3L keep 3/4, free 1/4
- * other keep that many bytes
- ! * -other keep all BUT that many bytes
- *
- * 02/14/90 ++jrb (thanks edgar)
- * auto acc detect
- --- 44,50 ----
- * 2L keep 2/4 (1/2), free rest
- * 3L keep 3/4, free 1/4
- * other keep that many bytes
- ! * -other keep |other| bytes and malloc from own heap
- *
- * 02/14/90 ++jrb (thanks edgar)
- * auto acc detect
- ***************
- *** 52,57 ****
- --- 65,73 ----
- * at startup, sp will be set to top of this area
- * (_heapbase + _stksize ) and malloc()'s will happen from heap.
- * (note malloc() and *not* Malloc())
- + * OR
- + * user sets only _stksize. then _heapbase is set to Malloc(_stksize)
- + * sp to _heapbase + _stksize and mallocs all happen from this heap.
- *
- * 02/16/90 ++jrb
- * - bug fix: dont get screwed by desktop launch when fast bit is set
- ***************
- *** 101,106 ****
- --- 117,125 ----
- /* are we an app? */
- short _app;
-
- + /* are we on a split addr mem ST */
- + short _split_mem = 0;
- +
- static void _acc_main __PROTO((void));
- static void _start1 __PROTO((BASEPAGE *bp));
- static long parseargs __PROTO((BASEPAGE *bp));
- ***************
- *** 148,154 ****
- --- 167,189 ----
- jeq __start0 /* br if prog */
- tstl a0@(36) /* tst parent basepage pointer */
- jne __start0 /* its a prog if != 0 */
- +
- + /* its an acc, set up a stck+heap */
- movl a0,__base /* sto basepage */
- + tstl __heapbase /* setup _heapbase and sp */
- + jne 1f
- + movl __stksize,d3 /* _heapbase not specified */
- + addql #3, d3
- + andl #0xfffffffc,d3
- + movl d3,sp@- /* _heapbase = Malloc(_stksize) */
- + movw #0x48,sp@-
- + trap #1
- + addqw #6,sp
- + movl d0, __heapbase
- + addl d3,d0
- + movl d0, sp /* sp = _heapbase + _stksize */
- + jra __acc_main
- + 1: /* heap base specified */
- movl __heapbase,sp /* setup sp */
- addl __stksize,sp
- jra __acc_main"); /* acc main */
- ***************
- *** 179,188 ****
- }
-
- static void _start1(bp)
- ! register BASEPAGE *bp;
- {
- ! register long m;
- ! register long freemem;
-
- _app = 1; /* its an application */
- _base = bp;
- --- 214,223 ----
- }
-
- static void _start1(bp)
- ! register BASEPAGE *bp __asm("a3");
- {
- ! register long m __asm("d3");
- ! register long freemem __asm("d4");
-
- _app = 1; /* its an application */
- _base = bp;
- ***************
- *** 205,213 ****
- _stksize = _initial_stack;
- }
-
- switch(_stksize)
- {
- ! case -1L: /* keep all but MINFREE, and malloc from own heap */
- _stksize = freemem;
- _heapbase = (void *) ((long)bp->p_tbase + m);
- break;
- --- 240,259 ----
- _stksize = _initial_stack;
- }
-
- + if((_stksize < 0) && (_stksize != -1L))
- + {
- + _heapbase = (void *) ((long)bp->p_tbase + m);
- + _stksize = -_stksize - 1;
- + }
- +
- + if((!_initial_stack) && (_stksize >= -1L))
- + { /* keep all, malloc from Malloc first, then from own heap */
- + _split_mem = 1;
- + }
- +
- switch(_stksize)
- {
- ! case -1L: /* keep all but MINFREE */
- _stksize = freemem;
- _heapbase = (void *) ((long)bp->p_tbase + m);
- break;
- ***************
- *** 227,238 ****
- case 3L: /* keep 3/4, free 1/4 */
- _stksize = freemem - (freemem >> 2);
- break;
- !
- default:
- - if(_stksize < 0) /* keep all but |_stksize| */
- - if((_stksize = freemem + _stksize) <= 0L)
- - goto notenough;
- /* if _stksize > 0, keep that much */
- }
-
- /* make m the total number of bytes including stack */
- --- 273,282 ----
- case 3L: /* keep 3/4, free 1/4 */
- _stksize = freemem - (freemem >> 2);
- break;
- !
- default:
- /* if _stksize > 0, keep that much */
- + break;
- }
-
- /* make m the total number of bytes including stack */
- *** 1.1 1991/07/23 22:06:28
- --- fcntl.c 1992/01/14 18:51:13
- ***************
- *** 7,12 ****
- --- 7,13 ----
- #include <fcntl.h>
- #include <stdarg.h>
- #include <errno.h>
- + #include <unistd.h>
-
- #ifdef __STDC__
- int fcntl (int f, int cmd, ...)
- *** 1.7 1991/04/26 03:42:08
- --- fdopen.c 1992/01/14 18:51:13
- ***************
- *** 10,16 ****
- register int h;
- const register char *mode;
- {
- ! extern int __default_mode__; /* see fopen.c */
- register int i, iomode = 0, f = __default_mode__;
- register FILE *fp = NULL;
- void _getbuf(FILE *);
- --- 10,16 ----
- register int h;
- const register char *mode;
- {
- ! extern int __default_mode__; /* see binmode.c */
- register int i, iomode = 0, f = __default_mode__;
- register FILE *fp = NULL;
- void _getbuf(FILE *);
- *** 1.8 1991/04/26 03:42:08
- --- findfile.c 1992/01/14 18:51:14
- ***************
- *** 19,26 ****
- #endif
-
- /* characters used to separate components in a path list */
- ! #define PATHSEP1 ','
- ! #define PATHSEP2 ';'
-
- /* characters used to separate directory names in a file */
- #define DIRSEP1 '\\' /* native OS directory separator */
- --- 19,26 ----
- #endif
-
- /* characters used to separate components in a path list */
- ! #define PATHSEP1 ':'
- ! #define PATHSEP2 ','
-
- /* characters used to separate directory names in a file */
- #define DIRSEP1 '\\' /* native OS directory separator */
- *** 1.14 1991/09/24 16:44:02
- --- fopen.c 1992/01/14 18:51:15
- ***************
- *** 13,41 ****
- /* lowest character device handle # */
- #define LAST_DEVICE __SMALLEST_VALID_HANDLE
-
- ! /*
- ! * added _binmode()
- ! * if called with TRUE, then subsequently all fopens have _IOBIN
- ! * by default on open. This will make life much easier for
- ! * people who have been using the Gnu lib (any my job with the compiler
- ! * much easier too, dont't have to go hunting for fopens())
- ! * ++jrb;
- ! */
-
- - /* note, cant be static as fdopen.c uses it too, so does libg++ */
- - int __default_mode__ = 0;
- -
- static FILE *_fopen __PROTO((const char *filename, const char *mode, FILE *fp));
- -
- - void _binmode(force)
- - int force;
- - {
- - if(force)
- - __default_mode__ = _IOBIN;
- - else
- - __default_mode__ = 0;
- - }
- -
-
- static FILE *_fopen(filename, mode, fp)
- const char *filename;
- --- 13,21 ----
- /* lowest character device handle # */
- #define LAST_DEVICE __SMALLEST_VALID_HANDLE
-
- ! extern int __default_mode__;
-
- static FILE *_fopen __PROTO((const char *filename, const char *mode, FILE *fp));
-
- static FILE *_fopen(filename, mode, fp)
- const char *filename;
- *** 1.9 1991/04/23 16:04:12
- --- fread.c 1992/01/14 18:51:17
- ***************
- *** 62,68 ****
- }
- else
- { /* read in n bytes into data */
- ! l += _read(fp->_file, data, (unsigned long)n);
- }
- }
- ret:
- --- 62,75 ----
- }
- else
- { /* read in n bytes into data */
- ! if((cnt = _read(fp->_file, data, (unsigned long)n))<=0) {
- ! fp->_flag |= ((cnt == 0) ? _IOEOF : _IOERR);
- ! goto ret;
- ! }
- ! data+=cnt;
- ! l+=cnt;
- ! n-=cnt;
- ! goto again;
- }
- }
- ret:
- *** 1.6 1991/06/23 17:07:09
- --- gmon.c 1992/01/14 18:51:24
- ***************
- *** 622,628 ****
- }
- /* otherwise find me in the chain and unlink */
- save_ssp = Super(0L);
- ! for(prev = this; this && (this != me); prev = this, this = this->next)
- {
- /* validate the xbra */
- if(this->xbra_magic != _XBRA_MAGIC)
- --- 622,630 ----
- }
- /* otherwise find me in the chain and unlink */
- save_ssp = Super(0L);
- ! for(prev = this; this && (this != me); prev = this,
- ! this = (xbra_struct *)((this->next)
- ! ? (((char *)(this->next)) - offsetof(xbra_struct, jump)) : 0))
- {
- /* validate the xbra */
- if(this->xbra_magic != _XBRA_MAGIC)
- *** 1.6 1991/04/26 03:42:08
- --- ioctl.c 1992/01/14 18:51:25
- ***************
- *** 12,17 ****
- --- 12,18 ----
- #include <osbind.h>
- #include <device.h>
- #include <unistd.h>
- + #include <linea.h> /* for TIOCGWINSZ under TOS */
-
- int
- ioctl(fd, func, arg)
- ***************
- *** 81,86 ****
- --- 82,101 ----
- __tchars[TC_WERASC] = ltc->t_werasc;
- __tchars[TC_LNEXTC] = ltc->t_lnextc;
- break;
- +
- + case TIOCSWINSZ:
- + break;
- +
- + case TIOCGWINSZ:
- + {
- + struct winsize *win = (struct winsize *)arg;
- +
- + (void)linea0();
- + win->ws_row = V_CEL_MY + 1;
- + win->ws_col = V_CEL_MX + 1;
- + win->ws_xpixel = V_X_MAX;
- + win->ws_ypixel = V_Y_MAX;
- + }
-
- default:
- errno = EINVAL;
- *** 1.8 1991/04/26 03:42:08
- --- isatty.c 1992/01/14 18:51:25
- ***************
- *** 19,27 ****
- if ((short)handle < 0)
- return(1);
-
- ! if ((dev = _dev_fd(fd)) && dev->open) /* a special device */
- ! return 0;
- !
- if (handle < __NHANDLES)
- if (__open_stat[handle].status != FH_UNKNOWN)
- return(__open_stat[handle].status == FH_ISATTY);
- --- 19,30 ----
- if ((short)handle < 0)
- return(1);
-
- ! dev = _dev_fd(fd);
- ! if (dev && ((dev->open) || (dev->dev == 0xfffd)))
- ! { /* a special device or PRN: */
- ! return 0;
- ! }
- !
- if (handle < __NHANDLES)
- if (__open_stat[handle].status != FH_UNKNOWN)
- return(__open_stat[handle].status == FH_ISATTY);
- *** 1.4 1991/06/11 23:04:27
- --- lib.h 1992/01/14 18:51:26
- ***************
- *** 44,49 ****
- __EXTERN char *_itoa __PROTO((int, char *, int));
-
- #endif /* _LIB_H */
- -
- -
- -
- --- 44,46 ----
- *** 1.11 1991/04/26 03:42:08
- --- localtim.c 1992/01/14 18:51:27
- ***************
- *** 73,81 ****
- y = (t->tm_mday - 1) + mth_start[t->tm_mon] + /* leap year correction */
- ( ( (t->tm_year % 4) != 0 ) ? 0 : (t->tm_mon > 1) );
-
- ! s = (t->tm_sec) + (t->tm_min * 60L) + (t->tm_hour * 3600L) +
- ! (y * 86400L) + ((t->tm_year - 70) * 31536000L) +
- ! ((t->tm_year - 69)/4) * 86400L;
-
- /* Now adjust for the time zone and possible daylight savings time */
- /* note that we have to call tzset() every time; see 1003.1 sect 8.1.1 */
- --- 73,81 ----
- y = (t->tm_mday - 1) + mth_start[t->tm_mon] + /* leap year correction */
- ( ( (t->tm_year % 4) != 0 ) ? 0 : (t->tm_mon > 1) );
-
- ! s = (t->tm_sec)+(t->tm_min*SECS_PER_MIN)+(t->tm_hour*SECS_PER_HOUR) +
- ! (y*SECS_PER_DAY)+((t->tm_year - 70)*SECS_PER_YEAR) +
- ! ((t->tm_year - 69)/4)*SECS_PER_DAY;
-
- /* Now adjust for the time zone and possible daylight savings time */
- /* note that we have to call tzset() every time; see 1003.1 sect 8.1.1 */
- *** 1.19 1991/05/23 14:43:17
- --- main.c 1992/01/14 18:51:27
- ***************
- *** 54,59 ****
- --- 54,62 ----
- /* supplied by the user */
- __EXTERN int main __PROTO((int, char **, char **));
-
- + /* in getbuf.c */
- + __EXTERN void _getbuf __PROTO((FILE *));
- +
- void
- _main(_argc, _argv, _envp)
- long _argc;
- ***************
- *** 62,69 ****
- char *tty;
- register FILE *f;
- register int i;
- ! void _getbuf(FILE *);
- ! extern int __default_mode__;
- int main(int, char **, char **);
-
- _start_time = 0; /* for dumped prgs */
- --- 65,72 ----
- char *tty;
- register FILE *f;
- register int i;
- ! char *s, *t, *new;
- ! extern int __default_mode__; /* in binmode.c or defined by user */
- int main(int, char **, char **);
-
- _start_time = 0; /* for dumped prgs */
- ***************
- *** 70,76 ****
- _start_time = clock();
- _child_runtime = _sys_runtime = 0;
- num_at_exit = 0;
- - errno = 0;
- /*
- * check for MiNT
- */
- --- 73,78 ----
- ***************
- *** 97,107 ****
- if(!*_argv[0] && isatty(2))
- (void)Fforce(2, _console_dev - 3);
-
- - /*
- - * FIX_ME: we should check to see if _binmode(TRUE) was set because
- - * of UNIXMODE.
- - */
- -
- stdin->_flag = _IOREAD|_IOFBF|__default_mode__;
- stdout->_flag = _IOWRT|_IOLBF|__default_mode__;
- stderr->_flag = _IORW|_IONBF|__default_mode__;
- --- 99,104 ----
- ***************
- *** 120,126 ****
- }
-
- for(i = 0; i <= __OPEN_INDEX(2); i++) {
- ! __open_stat[i].filename = NULL;
- }
-
- for(i = 3; i < _NFILE; i++, f++) {
- --- 117,125 ----
- }
-
- for(i = 0; i <= __OPEN_INDEX(2); i++) {
- ! __open_stat[i].filename = isatty(i) ?
- ! ((_console_dev == 2) ? "/dev/console" : "/dev/tty1")
- ! : (char *)NULL; /* if it was re-dir */
- }
-
- for(i = 3; i < _NFILE; i++, f++) {
- ***************
- *** 127,132 ****
- --- 126,165 ----
- f->_flag = 0; /* clear flags, if this is a dumped program */
- }
-
- + /* Fix up environment, if necessary. At present, the only variable
- + * affected is PATH; the "standard" path separators for PATH are
- + * ',' and ';' in the Atari world, but POSIX mandates ':'. This
- + * conflicts with the use of ':' as a drive separator, so we
- + * also convert names like A:\foo to /dev/A/foo
- + * NOTE: this conversion must be undone in spawn.c so that
- + * old fashioned programs will understand us!
- + */
- + for (i = 0; s = _envp[i]; i++) { /* '=', NOT '==' */
- + if (s[0] == 'P' && s[1] == 'A' && s[2] == 'T' &&
- + s[3] == 'H' && s[4] == '=') {
- + new = alloca(4*strlen(s));
- + strncpy(new, s, 5);
- + t = new+5;
- + s += 5;
- + while (*s) {
- + if (s[1] == ':') { /* drive letter */
- + *t++ = '/';
- + *t++ = 'd'; *t++ = 'e'; *t++ = 'v';
- + *t++ = '/'; *t++ = *s++; s++;
- + } else if (*s == ';' || *s == ',') {
- + *t++ = ':'; s++;
- + } else {
- + *t++ = *s++;
- + }
- + }
- + *t++ = 0;
- + _envp[i] = strdup(new);
- + break;
- + }
- + }
- +
- + errno = 0;
- +
- /* ANSI-Draft: A return from the initial call to the main */
- /* function is equivalent to calling the exit function with */
- /* the value returned by the main function as its argument. If */
- ***************
- *** 147,154 ****
- {
- register int i, f;
-
- - for(i = num_at_exit - 1; i >= 0; --i)
- - (*_at_exit[i])();
-
- for(i=0; i<_NFILE; ++i) {
- f = _iob[i]._flag;
- --- 180,185 ----
- ***************
- *** 158,163 ****
- --- 189,198 ----
- else
- fclose(&_iob[i]);
- }
- +
- + for(i = num_at_exit - 1; i >= 0; --i)
- + (*_at_exit[i])();
- +
- _exit(status);
- }
-
- *** 1.17 1991/09/24 16:44:02
- --- malloc.c 1992/01/14 18:51:28
- ***************
- *** 46,51 ****
- --- 46,52 ----
- struct mem_chunk *p, *q;
- long sz;
- extern void *_heapbase;
- + extern short _split_mem;
-
- /* add a mem_chunk to required size and round up */
- n = n + sizeof(struct mem_chunk);
- ***************
- *** 63,69 ****
- /* if not enough memory, get more from the system */
- if (q == NULL)
- {
- ! if ((_heapbase != NULL) || (n > MINHUNK))
- sz = n;
- else {
- sz = MINHUNK;
- --- 64,70 ----
- /* if not enough memory, get more from the system */
- if (q == NULL)
- {
- ! if (((!_split_mem) && (_heapbase != NULL)) || (n > MINHUNK))
- sz = n;
- else {
- sz = MINHUNK;
- ***************
- *** 108,113 ****
- --- 109,115 ----
- struct mem_chunk *o, *p, *q, *s;
- struct mem_chunk *r = (struct mem_chunk *) param;
- extern void *_heapbase;
- + extern short _split_mem;
-
- /* free(NULL) should do nothing */
- if (r == 0)
- ***************
- *** 155,161 ****
- r->size = 0;
- r->next = NULL;
- s = (struct mem_chunk * )(((long) p) + p->size);
- ! if (_heapbase != NULL && s >= (struct mem_chunk *) _heapbase) {
- assert(s == _heapbase);
- _heapbase = (char *) p;
- _stksize += p->size;
- --- 157,163 ----
- r->size = 0;
- r->next = NULL;
- s = (struct mem_chunk * )(((long) p) + p->size);
- ! if ((!_split_mem) && _heapbase != NULL && s >= (struct mem_chunk *) _heapbase) {
- assert(s == _heapbase);
- _heapbase = (char *) p;
- _stksize += p->size;
- ***************
- *** 165,171 ****
- else
- {
- s = (struct mem_chunk * )(((long) r) + r->size);
- ! if (_heapbase != NULL && s >= (struct mem_chunk *) _heapbase) {
- assert(s == _heapbase);
- _heapbase = (char *) r;
- _stksize += r->size;
- --- 167,173 ----
- else
- {
- s = (struct mem_chunk * )(((long) r) + r->size);
- ! if ((!_split_mem) && _heapbase != NULL && s >= (struct mem_chunk *) _heapbase) {
- assert(s == _heapbase);
- _heapbase = (char *) r;
- _stksize += r->size;
- *** 1.12 1991/09/24 16:44:02
- --- mincl 1992/01/14 18:51:30
- ***************
- *** 13,19 ****
-
- GCC= $(GLIB1) $(GLIB2) \
- ldexp.o frexp.o modf.o alloca.o setjmp.o osbind.o\
- ! linea.o alglobal.o sysvar.o gmon.o screen.o stksiz.o
- #
- # ANSI stuff + support
- ANSI = atol.o atof.o abort.o bsearch.o clock.o ctime.o ctype.o difftime.o \
- --- 13,19 ----
-
- GCC= $(GLIB1) $(GLIB2) \
- ldexp.o frexp.o modf.o alloca.o setjmp.o osbind.o\
- ! linea.o alglobal.o sysvar.o gmon.o screen.o stksiz.o binmode.o
- #
- # ANSI stuff + support
- ANSI = atol.o atof.o abort.o bsearch.o clock.o ctime.o ctype.o difftime.o \
- ***************
- *** 31,38 ****
- #
- # other portable stuff
- PORT = alphasor.o abs.o catch.o dirent.o findfile.o ftw.o getpw.o \
- ! getlogin.o getopt.o ident.o mktemp.o scandir.o strlwr.o strrev.o \
- ! regexp.o regsup.o textio.o random.o
-
- #
- # the string library
- --- 31,38 ----
- #
- # other portable stuff
- PORT = alphasor.o abs.o catch.o dirent.o findfile.o ftw.o getpw.o \
- ! getlogin.o getopt.o getpass.o ident.o mktemp.o scandir.o strlwr.o \
- ! strrev.o regexp.o regsup.o textio.o random.o
-
- #
- # the string library
- ***************
- *** 49,55 ****
- link.o lseek.o mkdir.o null.o open.o perror.o pipe.o popen.o psignal.o \
- read.o rename.o rmdir.o \
- sbrk.o sgtty.o signal.o siglist.o sleep.o spawnve.o spawnvp.o stat.o \
- ! symdir.o symlink.o tchars.o time.o times.o \
- unlink.o unx2dos.o utime.o vfork.o write.o
-
- #
- --- 49,55 ----
- link.o lseek.o mkdir.o null.o open.o perror.o pipe.o popen.o psignal.o \
- read.o rename.o rmdir.o \
- sbrk.o sgtty.o signal.o siglist.o sleep.o spawnve.o spawnvp.o stat.o \
- ! symdir.o symlink.o tchars.o time.o timeoday.o times.o \
- unlink.o unx2dos.o utime.o vfork.o write.o
-
- #
- *** 1.8 1991/06/11 23:04:27
- --- mkdir.c 1992/01/14 18:51:31
- ***************
- *** 11,18 ****
-
- extern int errno;
-
- ! int mkdir(_path)
- const char *_path;
- {
- int rv, name_munged;
- char path[FILENAME_MAX];
- --- 11,19 ----
-
- extern int errno;
-
- ! int mkdir(_path, mode)
- const char *_path;
- + int mode;
- {
- int rv, name_munged;
- char path[FILENAME_MAX];
- *** 1.9 1991/05/23 14:43:17
- --- mktemp.c 1992/01/14 18:51:31
- ***************
- *** 8,13 ****
- --- 8,14 ----
- #include <fcntl.h>
- #include <unistd.h>
- #include <assert.h>
- + #include <errno.h>
- #include "lib.h"
-
- #define TEN_MUL(X) ((((X) << 2) + (X)) << 1)
- ***************
- *** 18,23 ****
- --- 19,25 ----
- char * p, * q;
- long tempnum, nx;
- static int startat = 0;
- + int save_errno;
-
- assert((pattern != NULL));
-
- ***************
- *** 39,49 ****
- --- 41,56 ----
- }
- else
- startat++;
- + save_errno = errno;
- for(; tempnum < nx; tempnum++)
- {
- (void) _ltoa(tempnum, q, 10); /* assumption: strrev reverses in place */
- if(access(pattern, F_OK)) /* using access takes care of unx2dos also */
- + {
- + errno = save_errno;
- return pattern;
- + }
- }
- + errno = save_errno;
- return NULL;
- }
- *** 1.1 1991/09/24 16:44:02
- --- pipe.c 1992/01/14 18:51:33
- ***************
- *** 4,10 ****
- --- 4,14 ----
- #include <errno.h>
- #include <stdio.h>
- #include <stdlib.h>
- + #define __MINT__
- + #include <mintbind.h>
-
- + extern int __mint;
- +
- /**
- ** (sjk)++ These routines simulate a eunchs pipe() call using temporary
- ** files. A linked list of type *_pipe is kept as to allow as
- ***************
- *** 23,28 ****
- --- 27,33 ----
- struct _pipe *next;
- };
- static struct _pipe *__pipes = NULL;
- + static int del_list (struct _pipe *);
-
- /*---------------------------------------------------------------------------*/
- /* Make a pipe, open the tempory file, set it up for writing, add the pipe */
- ***************
- *** 41,46 ****
- --- 46,55 ----
- /*----------------------------------------------*/
- fd = open(name,O_CREAT | O_TRUNC | O_RDWR | O_PIPE, 0644);
-
- + #if defined(DEBUG)
- + fprintf(stderr,"opened pipe - fd : %d.\n",fd);
- + #endif
- +
- if (fd < 0)
- fprintf(stderr,"fd returns : %d! PIPE(%s) failed.\n",fd, name);
- else
- ***************
- *** 60,65 ****
- --- 69,76 ----
- __pipes = p;
- /*-------------------------------------------------------------------*/
- fildes[0] = fildes[1] = fd; /* we fill in fildes[]. */
- + if (__mint)
- + Fcntl(fd,0L,2); /* Make fd shared across Pexecs() */
- }
- return(fd); /* Return the file descriptor. */
- }
- ***************
- *** 77,82 ****
- --- 88,97 ----
- int ifd;
- for (p=__pipes; p; p=p->next)
- { if (fd == p->file_des)
- + {
- + #if defined(DEBUG)
- + fprintf(stderr,"Deleting pipe - mode : %c, fd : %d\n",p->flag,fd);
- + #endif
- if (p->flag == 'r')
- { int res;
- ifd = __OPEN_INDEX(fd);
- ***************
- *** 92,97 ****
- --- 107,113 ----
- lseek(p->file_des,0,SEEK_SET); /* read from the start. */
- return(0);
- }
- + }
- }
- fprintf(stderr,"attempt to close nonexistant pipe.\n");
- return(-1);
- ***************
- *** 100,106 ****
- /*---------------------------------------------------------------------*/
- /* delete a pipe descriptor from our list of pipes rooted ar __pipes. */
- /*---------------------------------------------------------------------*/
- ! del_list(p)
- struct _pipe *p;
- { struct _pipe *q,*r;
-
- --- 116,122 ----
- /*---------------------------------------------------------------------*/
- /* delete a pipe descriptor from our list of pipes rooted ar __pipes. */
- /*---------------------------------------------------------------------*/
- ! static int del_list(p)
- struct _pipe *p;
- { struct _pipe *q,*r;
-
- ***************
- *** 110,116 ****
- return(0);
- }
- else
- ! { r = p->next; q = p; /* No it is interior. */
- for (; r; r = r->next)
- { if (r == p)
- { q->next = r->next; /* pass over it. */
- --- 126,132 ----
- return(0);
- }
- else
- ! { r = __pipes->next; q = __pipes; /* No it is interior. */
- for (; r; r = r->next)
- { if (r == p)
- { q->next = r->next; /* pass over it. */
- ***************
- *** 121,125 ****
- }
- }
- fprintf(stderr,"Attempt to delete a nonexisting pipe form list (__pipes).");
- }
- -
- --- 137,141 ----
- }
- }
- fprintf(stderr,"Attempt to delete a nonexisting pipe form list (__pipes).");
- + return(-1);
- }
- *** 1.3 1991/04/12 18:19:53
- --- popen.c 1992/01/14 18:51:33
- ***************
- *** 29,35 ****
- char pmode; /* "r" or "w" to/from the pipe ? */
- char *pcommand; /* cmd to execute (only for "w") */
- int pstat; /* exit code of cmd (only for "r") */
- ! char pname[20]; /* temp filename. 20 should be enough...*/
- FILE *pfile; /* pipe identifier */
- struct _pipe *pnext; /* next pipe in the list. */
- };
- --- 29,35 ----
- char pmode; /* "r" or "w" to/from the pipe ? */
- char *pcommand; /* cmd to execute (only for "w") */
- int pstat; /* exit code of cmd (only for "r") */
- ! char pname[32]; /* temp filename. 32 should be enough...*/
- FILE *pfile; /* pipe identifier */
- struct _pipe *pnext; /* next pipe in the list. */
- };
- ***************
- *** 36,43 ****
-
- static struct _pipe *__pipes = NULL; /* head of pipe list */
-
- - static char ptmp[] = "pipeXXXX"; /* skeleton for temp filename */
- -
- /* open a pipe to the command argument in the mode given by the type string.
- * If caller wants to read the pipe, redirect output and execute command,
- * then open the temp file and return that. If caller wants to write to
- --- 36,41 ----
- ***************
- *** 55,64 ****
- /* initialize the new pipe entry */
- p->pmode = *type;
- p->pfile = (FILE *) NULL;
- ! strcpy(p->pname,ptmp);
- ! mktemp(p->pname);
- /* make command line with appropriate re-direction */
- ! if((p->pcommand = (char *)malloc(strlen(command)+strlen(ptmp)+4L))
- == (char *)NULL)
- { /* no mem */
- free(p);
- --- 53,61 ----
- /* initialize the new pipe entry */
- p->pmode = *type;
- p->pfile = (FILE *) NULL;
- ! (void)tmpnam(p->pname);
- /* make command line with appropriate re-direction */
- ! if((p->pcommand = (char *)malloc(strlen(command)+strlen(p->pname)+4L))
- == (char *)NULL)
- { /* no mem */
- free(p);
- *** 1.13 1991/06/11 23:04:27
- --- rename.c 1992/01/14 18:51:35
- ***************
- *** 18,23 ****
- --- 18,24 ----
- SYMDIR *olddir = 0, *newdir = 0;
- SYMENTRY *ent = 0, *old;
- char *s;
- + int save_errno = errno;
-
- if (!access(_newname, 0)) { /* new name already exists */
- #ifdef DEBUG
- ***************
- *** 26,31 ****
- --- 27,33 ----
- if (unlink(_newname))
- return -1;
- }
- + errno = save_errno;
-
- rval = unx2dos(_oldname, oldname);
- /* unx2dos returns _NM_LINK and sets __link_path and __link_name if
- *** 1.7 1991/06/23 17:07:09
- --- sbrk.c 1992/01/14 18:51:36
- ***************
- *** 15,20 ****
- --- 15,21 ----
-
- extern void *_heapbase;
- extern long _stksize;
- + extern short _split_mem;
-
- static void * HeapAlloc( sz )
- size_t sz ;
- ***************
- *** 43,49 ****
- {
- void *rval;
-
- ! if(_heapbase != NULL)
- {
- if(n) rval = HeapAlloc(n);
- else rval = _heapbase;
- --- 44,50 ----
- {
- void *rval;
-
- ! if((!_split_mem) && (_heapbase != NULL))
- {
- if(n) rval = HeapAlloc(n);
- else rval = _heapbase;
- ***************
- *** 54,59 ****
- --- 55,65 ----
- }
- if (rval == NULL)
- {
- + if(_split_mem)
- + { /* now switch over to own heap for further requests, including this one */
- + _split_mem = 0;
- + return lsbrk(n);
- + }
- errno = ENOMEM;
- rval = (void *)-1;
- }
- *** 1.14 1991/07/23 22:06:28
- --- spawnve.c 1992/01/14 18:51:39
- ***************
- *** 22,27 ****
- --- 22,28 ----
- #include <time.h>
- #include <string.h>
- #include <fcntl.h>
- + #include <unistd.h>
- #include "lib.h"
-
- extern char **environ;
- ***************
- *** 29,35 ****
- clock_t _child_runtime;
- clock_t _sys_runtime;
-
- ! static char cmd[NCARGS+1];
-
- /*
- * FIXME: currently mode == P_OVERLAY doesn't work as advertised, i.e. it
- --- 30,37 ----
- clock_t _child_runtime;
- clock_t _sys_runtime;
-
- ! #define TOS_ARGS 126
- ! static char cmd[TOS_ARGS+1];
-
- /*
- * FIXME: currently mode == P_OVERLAY doesn't work as advertised, i.e. it
- ***************
- *** 73,85 ****
- return -1;
- }
- s = env;
- ! while (*envp) {
- ! for (p = *envp ; *p ; )
- ! *s++ = *p++;
- *s++ = '\0';
- envp++;
- }
- -
- strcpy(s, "ARGV=");
- s += 6; /* s+=sizeof("ARGV=") */
-
- --- 75,108 ----
- return -1;
- }
- s = env;
- ! while ((p = *envp) != 0) {
- ! /*
- ! * NOTE: in main.c, we converted the PATH environment variable into
- ! * POSIX form. Here, we convert back into gulam form. Note that the
- ! * new variable will be shorter than the old, so space is not a problem.
- ! */
- ! if (!strncmp(p, "PATH=", 5)) {
- ! strncpy(s, p, 5); s += 5; p += 5;
- ! while (*p) {
- ! if (!strncmp(p, "/dev/", 5) && p[5]) {
- ! *s++ = p[5];
- ! *s++ = ':';
- ! p += 6;
- ! } else if (*p == ':') {
- ! *s++ = ','; p++;
- ! } else if (*p == '/') {
- ! *s++ = '\\'; p++;
- ! } else {
- ! *s++ = *p++;
- ! }
- ! }
- ! } else {
- ! while(*p)
- ! *s++ = *p++;
- ! }
- *s++ = '\0';
- envp++;
- }
- strcpy(s, "ARGV=");
- s += 6; /* s+=sizeof("ARGV=") */
-
- ***************
- *** 100,111 ****
- while (*++argv) {
- p = *argv;
- while (*p) {
- ! if (cmlen <= NCARGS) {
- *t++ = *p; cmlen++;
- }
- *s++ = *p++;
- }
- ! if (cmlen <= NCARGS && *(argv+1)) {
- *t++ = ' '; cmlen++;
- }
- *s++ = '\0';
- --- 123,134 ----
- while (*++argv) {
- p = *argv;
- while (*p) {
- ! if (cmlen <= TOS_ARGS) {
- *t++ = *p; cmlen++;
- }
- *s++ = *p++;
- }
- ! if (cmlen <= TOS_ARGS && *(argv+1)) {
- *t++ = ' '; cmlen++;
- }
- *s++ = '\0';
- *** 1.15 1991/07/23 22:06:28
- --- stat.c 1992/01/14 18:51:40
- ***************
- *** 245,251 ****
- int old;
- int r;
- struct _device *dev = _dev_fd(fd);
- !
- if(dev)
- {
- char *devname = (char *)alloca(strlen(dev->unxnm) + 6L);
- --- 245,251 ----
- int old;
- int r;
- struct _device *dev = _dev_fd(fd);
- !
- if(dev)
- {
- char *devname = (char *)alloca(strlen(dev->unxnm) + 6L);
- ***************
- *** 253,270 ****
- (void) strcat(devname, dev->unxnm);
- return stat(devname, st);
- }
- !
- fd = __OPEN_INDEX(fd);
- if((fd >= 0) && (fd < __NHANDLES))
- {
- ! /* we should turn off links, because the name we're going to give
- ! * to 'stat' has already been unx2dos'd
- ! */
- ! old = _lOK;
- ! _lOK = 0;
- ! r = stat(__open_stat[fd].filename, st);
- ! _lOK = old;
- ! return r;
- }
- errno = EBADF;
- return -1;
- --- 253,323 ----
- (void) strcat(devname, dev->unxnm);
- return stat(devname, st);
- }
- !
- fd = __OPEN_INDEX(fd);
- if((fd >= 0) && (fd < __NHANDLES))
- {
- ! if (__open_stat[fd].filename) {
- ! /* we should turn off links, because the name we're going to give
- ! * to 'stat' has already been unx2dos'd
- ! */
- ! old = _lOK;
- ! _lOK = 0;
- ! r = stat(__open_stat[fd].filename, st);
- ! _lOK = old;
- ! return r;
- ! } else {
- ! _DOSTIME timestruct;
- !
- ! /* the following code is stolen from Eric R. Smith */
- ! r = Fdatime(×truct, fd, 0);
- ! if (r < 0) { /* assume TTY */
- ! st->st_mode = S_IFCHR | 0600;
- ! st->st_attr = 0;
- ! st->st_mtime = st->st_ctime = st->st_atime =
- ! time((time_t *)0) - 2;
- ! st->st_size = 0;
- ! } else {
- ! long oldplace;
- !
- ! st->st_mtime = st->st_atime = st->st_ctime =
- ! unixtime(timestruct.time,timestruct.date);
- ! st->st_mode = S_IFREG | 0644; /* this may be false */
- ! st->st_attr = 0; /* because this is */
- !
- ! /* get current file location */
- ! oldplace = Fseek(0L, fd, SEEK_CUR);
- ! if (oldplace < 0) { /* can't seek -- must be pipe */
- ! st->st_mode = S_IFIFO | 0644;
- ! st->st_size = 1024;
- ! } else {
- ! short magic;
- ! r = Fseek(0L, fd, SEEK_END); /* go to end of file */
- ! st->st_size = r;
- ! (void)Fseek(0L, fd, SEEK_SET); /* go to start of file */
- ! /* check for executable file */
- ! if (_x_Bit_set_in_stat &&
- ! Fread(fd, 2, (char *)&magic) == 2) {
- ! if (magic == 0x601a || magic == 0x2321)
- ! st->st_mode |= 0111;
- ! }
- ! (void)Fseek(oldplace, fd, SEEK_SET);
- ! }
- ! }
- !
- ! /* all this stuff is likely bogus as well. sigh. */
- ! st->st_dev = Dgetdrv();
- ! st->st_rdev = 0;
- ! st->st_uid = getuid();
- ! st->st_gid = getgid();
- ! st->st_blksize = 1024;
- ! /* note: most Unixes measure st_blocks in 512 byte units */
- ! st->st_blocks = (st->st_size + 511) / 512;
- ! st->st_ino = ++__inode;
- ! st->st_nlink = 1;
- ! return 0;
- !
- ! }
- }
- errno = EBADF;
- return -1;
- *** 1.7 1991/06/11 23:04:27
- --- symlink.c 1992/01/14 18:51:47
- ***************
- *** 21,27 ****
- SYMDIR *dir;
- SYMENTRY *d;
- char *s;
- ! int r;
-
- /* Problem: to TOS, "Makefile", "Makefile", and "makefilefoo" are all
- * identical. Fortunately, unx2dos can distinguish them, and
- --- 21,27 ----
- SYMDIR *dir;
- SYMENTRY *d;
- char *s;
- ! int r, save_errno;
-
- /* Problem: to TOS, "Makefile", "Makefile", and "makefilefoo" are all
- * identical. Fortunately, unx2dos can distinguish them, and
- ***************
- *** 33,43 ****
- --- 33,45 ----
- * is redundant).
- */
-
- + save_errno = errno;
- r = unx2dos(new, linkpath);
- if ((r == _NM_LINK) || (r == _NM_OK) && !access(new, 0)) {
- errno = EEXIST;
- return -1;
- }
- + errno = save_errno;
-
- /*
- * find the name (from the original path in "new"), and the canonical form
- ***************
- *** 99,104 ****
- --- 101,107 ----
- char tmp[FILENAME_MAX], linkpath[FILENAME_MAX], *s, *lastslash = 0;
- SYMDIR *dir;
- SYMENTRY *ent;
- + size_t len;
-
- strcpy(tmp, filename);
- for (s = tmp; *s; s++) {
- ***************
- *** 105,111 ****
- if (*s == '\\' || (_tSLASH && (*s == '/')))
- lastslash = s;
- }
- ! if (lastslash) {
- *lastslash++ = 0;
- unx2dos(tmp, linkpath);
- }
- --- 108,117 ----
- if (*s == '\\' || (_tSLASH && (*s == '/')))
- lastslash = s;
- }
- ! if (lastslash==tmp) {
- ! lastslash++;
- ! unx2dos("/",linkpath);
- ! } else if (lastslash) {
- *lastslash++ = 0;
- unx2dos(tmp, linkpath);
- }
- ***************
- *** 123,128 ****
- return -1;
- }
- strncpy(linkto, ent->linkto, siz);
- _free_symdir(dir);
- ! return strlen(linkto);
- }
- --- 129,140 ----
- return -1;
- }
- strncpy(linkto, ent->linkto, siz);
- +
- + /* must get length right */
- + len=strlen(ent->linkto);
- + if (len>siz) {
- + len=siz;
- + }
- _free_symdir(dir);
- ! return len;
- }
- *** 1.17 1991/06/23 17:07:09
- --- unlink.c 1992/01/14 18:51:50
- ***************
- *** 13,18 ****
- --- 13,19 ----
- #include "lib.h"
-
- #define error(x) ((errno = (x)), -1)
- + __EXTERN char *strdup __PROTO((const char *s));
-
- /* remove provided for ansi compatibility */
- #ifndef __GNUC__
- ***************
- *** 35,42 ****
-
- d = D;
- while (d) {
- (void)Fdelete(d->fname);
- ! d = d->next;
- }
- }
-
- --- 36,46 ----
-
- d = D;
- while (d) {
- + if(d->fname) {
- (void)Fdelete(d->fname);
- ! free(d->fname);
- ! }
- ! d = d->next;
- }
- }
-
- ***************
- *** 98,105 ****
- return error(ENOMEM);
- }
- /* hook the new "delete" structure into the chain */
- ! d->fname = name;
- d->next = D; D = d;
- /* if there was an automatic link, delete it now */
- if (ent)
- goto unlink_sym;
- --- 102,119 ----
- return error(ENOMEM);
- }
- /* hook the new "delete" structure into the chain */
- ! d->fname = strdup(name);
- d->next = D; D = d;
- + if(!(d->fname)) {
- + /* note we link it in and then check, as
- + we cannot undo the atexit(), (nor do we
- + want to because there maybe others on the
- + chain already). in do_deletes we'll
- + just skip the null name entries */
- + _free_symdir(dir);
- + return error(ENOMEM);
- + }
- +
- /* if there was an automatic link, delete it now */
- if (ent)
- goto unlink_sym;
-